package com.smartStatus.admin.activemq;

import com.alibaba.fastjson.JSONObject;
import com.smartStatus.api.entity.SysUser;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQMessage;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author: liuby5
 * @CreateTime: 2022-09-01  16:17
 * @Description: mq 发送工具类
 * @Version: 1.0
 */
@Component
@Slf4j
public class ActiveMqUtils {
    @Resource
    JmsTemplate jmsTemplate;


    /**
     * mq 发送信息
     *
     * @param queueName
     * @param msg
     */
    public void sendMsg(String queueName, String msg) {
        log.info("开始发送mq信息,队列名称为:{},消息内容为:{}", queueName, msg);
        ActiveMQQueue activeMQQueue = new ActiveMQQueue(queueName);
        jmsTemplate.setDefaultDestination(activeMQQueue);
        jmsTemplate.convertAndSend(msg);
    }


}
